package com.shelpe.services.tenant.proxy;

import java.util.List;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.fasterxml.jackson.annotation.JsonProperty;


import lombok.Data;

@FeignClient(name="${simbaproxy.serviceID}", url="${simbaproxy.url}")
@RequestMapping(value = "/simba")
public interface RecommendClient {

	/**
	 * 获取推荐词
	 * 
	 * */
	@RequestMapping(method = RequestMethod.GET, value = "/taobao.simba.keywords.recommend.get")
	public RecommendKeywordResponse getRecommandWordByAdgroupId(@RequestParam("nick") String nick, @RequestParam("adgroup_id") long adgroupId, @RequestParam("search") long search,
			@RequestParam("pertinence") String pertinence, @RequestParam("order_by") String order, 
			@RequestParam("page_size")int pageSize, @RequestParam("page_no")int pageNo);
	
	/**
	 * 获取相关词
	 * 
	 * */
	@RequestMapping(method = RequestMethod.GET, value = "/taobao.simba.insight.relatedwords.get")
	public RelatedWordResponse getRelatedWord(@RequestHeader("tenantID") long userId, @RequestParam("bidword_list") String bidword, @RequestParam("number") long num);
	
	@Data
	public static class RecommendKeywordResponse extends SimbaProxyBaseDto{
		@JsonProperty("simba_keywords_recommend_get_response")
		private RecommendKeywordRes res;
	}
	
	@Data
	public static class RecommendKeywordRes{
		@JsonProperty("recommend_words")
		private RecommendWordPage page;
	}
	
	@Data
	public static class RecommendWordPage{
		
		@JsonProperty("page_size")
		private int pageSize;
		@JsonProperty("total_item")
		private int totalItem;
		@JsonProperty("page_no")
		private int pageNo;
		@JsonProperty("recommend_word_list")
		private RecommendWords list;
	}
	
	@Data
	public static class RecommendWords {
		@JsonProperty("recommend_word")
		private List<RecommendWord> words;
	}
	
	@Data
	public static class RecommendWord{
		private String pertinence;//相关度
		private String word;
		@JsonProperty("pv")
		private String searchVolume;//搜索量
		@JsonProperty("average_price")
		private String averagePrice;//平均价格
	}
	
	/********************************/
	
	@Data
	public static class RelatedWordResponse extends SimbaProxyBaseDto{
		@JsonProperty("simba_insight_relatedwords_get_response")
		private RelatedWordRes res;
	}
	
	@Data
	public static class RelatedWordRes{
		@JsonProperty("related_words_result_list")
		private RelatedWordInsightRes insightRes;
	}
	
	@Data
	public static class RelatedWordInsightRes{
		@JsonProperty("insight_related_words")
		private List<WordRelationDataList> dataList;
	}
	
	@Data
	public class WordRelationDataList {
		@JsonProperty("bidword")
		private String word;
		@JsonProperty("related_word_items_list")
		private RelatedWords relatedWords;
	}
	
	@Data
	public class RelatedWords {
		@JsonProperty("insight_related_word")
		private List<RelatedWord> words;
	}
	
	@Data
	public class RelatedWord{
		@JsonProperty("related_word")
		private String word;
		private String weight;
	}
	
}
